class Api::StudentController < ApplicationController

  def search
    key = params[:key]
    #search entity by login, email, or studentcode in profile
    @result = Student.find_by_sql("SELECT a.id,a.login,a.email,b.studentcode FROM students a LEFT JOIN student_profiles b ON b.student_id = a.id WHERE a.login LIKE '%"+key+"%' OR a.email LIKE '%"+key+"%' OR b.studentcode LIKE '%"+key+"%'")
    respond_to do |format|
      #format.html # index.html.erb
      format.xml  { render :xml => @result }
      format.json { render :json => @result }
    end
  end

  def info

  end
end
